<?php
namespace App\Models\WechatMsg;

use App\Models\RewardTimeApply;
use App\Models\RewardTimeHistory;
use App\Models\UserClock;
use App\Models\UserProject;
use App\Models\UserTeam;

class ApplyReward
{
    public  $type;
    public $content;

    public function __construct($type, $content)
    {
        $this->content = $content;
        $this->type = $type;
    }

    public function getOrgWechatConfig()
    {
        $apply = RewardTimeApply::where('id', $this->content['reward_time_apply_id'])->first();

        $conf['templateId'] = $apply->user->org->wechat_message_config['reward_time_patch_vol'];

        $options = config('wechat');

        $options['app_id'] = $apply->user->org->wechat_app_id;
        $options['secret'] = $apply->user->org->wechat_app_secret;

        $conf['options'] = $options;

        $conf['openId'] = $apply->user->open_id;

        $conf['url'] = $apply->user->org->getBaseUrl().'/my/duration/applys';

        return $conf;
    }


    public function getMessageData()
    {
        $apply = RewardTimeApply::where('id', $this->content['reward_time_apply_id'])->first();


        $data['first'] = $this->type == 7? "您的补录时长申请已通过":"您的补录时长申请未通过";

        $data['keyword1'] =  "《{$apply->project->name}项目》补录时长申请";
        $data['keyword2'] = $this->type == 7? '已通过':'已拒绝';
        $data['remark'] = '感谢您的使用';

        return $data;
    }

}